<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    <script>
        function formate(url, data) {
            let type = "get";
            if (arguments.length === 1) {
                type = "post";
                data = url;
                url = "";
            }
            let start = true;
            for (let key in data) {
                if (type === "get") {
                    url += (start ? "?" : "&") + key + "=" + data[key];
                } else if (type === "post") {
                    url += (start ? "" : "&") + key + "=" + data[key];
                }
                start = false;
            }
            return url;
        }

        function ajax(method, url, _callback, data) {
            data.jsonpcallback = data.jsonpcallback ? data.jsonpcallback : "callback";
            let script = document.createElement("script");
            script.src = formate(url, data);
            document.body.appendChild(script);

            window[data.jsonpcallback] = (data) => {
                _callback(data);
            }

            script.onload = () => {
                script.remove();
            }
        }

        ajax("json", "https://api.gogoup.com/p1/data/recommend", function (data) {
            console.log(data);
        }, {
            type: 0,
            pageNo: 2,
            pageSize: 5,
            fromId: 379,
            _: Date.now()
        })
    </script>
</body>

</html>